﻿using System;

namespace Validity.Rules.Decorators
{
  public class ComparisonRuleDecorator<TObject, TValue>
    : RuleDecorator<TObject, TValue>, IComparisonRule<TObject, TValue>
    where TValue : IComparable
  {
    private readonly IComparisonRule<TObject, TValue> _rule;

    public ComparisonRuleDecorator(IComparisonRule<TObject, TValue> rule)
      : base(rule)
    {
      Verify.NotNull(rule);

      _rule = rule;
    }

    public virtual Boolean IsViolatedBy(TObject obj, TValue value, Comparison<TValue> comparer)
    {
      return _rule.IsViolatedBy(obj, value, comparer);
    }
  }
}
